home *** CD-ROM | disk | FTP | other *** search
- Path: ntc.nokia.com!usenet
- From: Hannu Kaikkonen <hannu.kaikkonen@ntc.nokia.com>
- Newsgroups: comp.lang.c++
- Subject: Screenprinting problem!
- Date: Wed, 21 Feb 1996 11:34:03 +0200
- Organization: Nokia Telecommunications Oy
- Message-ID: <312AE70B.4EEB@ntc.nokia.com>
- NNTP-Posting-Host: pc-hkaikkonen.ntc.nokia.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- I am making a program that reads characters from a com port. I can successfully get
- the characters to my hard disk. I can also use the EvChar and Paint functions to type
- key strokes to screen. What do I need to do to get characters from the com port to
- appear on the screen?? I guess I need to tell somehow to the windows to repaint the
- screen. My program is a modified example of the book teach yourself borland C++ 4.0 in
- 21 days (listing 14.5 Real.cpp). The idea of the program code is something like this
- (lot of stuff missing):
-
- class Alarms : public TWindow
- {
- protected:
- int currentLine; // line being typed in now
- int lineLen[maxLines]; // length of each line
- char *linePtrs[maxLines]; // string for each line
- BOOL isMinimized; // TRUE if window is an icon
- TSize windowSize; // structure with size pixels
- void Paint(TDC& dc, BOOL, TRect&);
- void EvSize(UINT sizeType, TSize& size);
- }
-
- Alarms::MyFunc()
- {
-
- Stuff needed to read the Com port. Characters are read to a string buffer.
- ReadComm(Com1DCB.Id,Buffer,300)
-
-
- }
-
- // Called when time to update (paint) the screen
- void Alarms::Paint(TDC& dc, BOOL, TRect&)
- {
- int lineNum; // line number to write
- int yPos; // vertical position on screen
- int displayedLines; // number of linePtrs in this window
- TSize textSize; // used to get char height in pixels
- if (isMinimized) // don┤t write to an icon
- return;
-
- // Get char sizes so that height is saved
- textSize = dc.GetTextExtent("W",1);
- displayedLines = windowSize.cy / textSize.cy;
-
- if (displayedLines > maxLines)
- displayedLines = maxLines;
-
- for (lineNum = yPos = 0; lineNum < displayedLines; ++lineNum)
- {
- if (lineLen[lineNum] > 0) // if any text on the line
- dc.TextOut(0, yPos, linePtrs[lineNum], lineLen[lineNum]);
-
- yPos += textSize.cy; // adjust screen line position
- }
- }
-